#! /usr/bin/env python2.4
"""
cgi test script for SimpleJSONRPCServer
"""
from SimpleJSONRPCServer import CGIJSONRPCRequestHandler
import xmlrpclib

class MyFuncs:
    def get_workflow_status(self, workflow_name):
        return workflow_rpc.get_workflow_status(workflow_name)

    def reactivate_completed_workflow(self, workflow_namedate_key, step_num):
        return workflow_rpc.reactivate_completed_workflow(workflow_namedate_key, step_num)
        
    def get_list_of_completed_workflows(self):
        return workflow_rpc.get_list_of_completed_workflows()

    def fd_step(self, workflow_name, input=None):
        workflow_rpc.fd_step(workflow_name, input)
        return 0
        
    def restart_workflow(self, workflow_name):
        workflow_rpc.fd_step(workflow_name)
        return 0
           
    def get_names_of_available_workflows(self):
        return workflow_rpc.get_names_of_available_workflows()
         
    def get_names_of_running_workflows(self):
        return workflow_rpc.get_names_of_running_workflows()
	    

workflow_rpc = xmlrpclib.Server('http://localhost:8000')

handler = CGIJSONRPCRequestHandler()
handler.register_function(pow)
handler.register_function(lambda x,y: x+y, 'add')
handler.register_introspection_functions()
handler.register_instance(MyFuncs())
handler.handle_request()


